#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#include <QMainWindow>
#include "server.h"
#include "client.h"
#include <QLineEdit>
#include <QTextEdit>
#include <QTcpSocket>
namespace Ui {
class ChatWindow;
}

class ChatWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit ChatWindow(QWidget *parent = nullptr);
    ~ChatWindow();
    QString getUserName() const;//获取用户名
private slots:
    //设置名字按钮槽
    void setNameButtonClicked();
    //添加好友按钮点击槽
    void addFriendButtonClicked();
    //发送信息按钮点击槽
    void sendMessageButtonClicked();
    //发送文件
    void sendFileButtonClicked();
    //处理新客户端连接
    void handleNewClientConnected(QTcpSocket *client);
    //处理信息接收
    void handleMessageReceived();
    //创建群聊
    void groupChatWindowButtonClicked();




private:
    Ui::ChatWindow *ui;
    QString userName;
    Server *chatServer;
    Client *chatClient;
    QMap<QString, QTcpSocket *> friendSockets;//储存好友名对应的socket
};

#endif // CHATWINDOW_H
